package com.qf.votesystem.controller;
import com.qf.votesystem.entity.service.IPhonenameService;
import com.qf.votesystem.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class VoteController {


    @Autowired
    IPhonenameService phonenameService;

    @PostMapping("/vote")
    public ResultVo vote(String phoneNum, String username, HttpServletRequest request){


        ResultVo resultVo = phonenameService.vote(phoneNum,username,request);

        return resultVo;
    }

    @PostMapping("/count")
    public Map<String, Integer> count(){

        Map<String, Integer> map = phonenameService.countTickets();

        return map;
    }
}
